﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Text.RegularExpressions;

namespace AzureTosser.Services
{
    public class TopicHelper
    {
        private static Regex mReg = new Regex("^\\w+(.\\w+)*$");
        /// <summary>
        /// Valid topic format is similar to domain format except:
        /// 1)case sensitive
        /// 2)numbers can be leading characters of segments
        /// </summary>
        /// <param name="topic">topic string to be checked</param>
        /// <returns>if topic string is in valid format</returns>
        public static bool IsValidTopic(string topic)
        {
            if (string.IsNullOrEmpty(topic))
                return false;
            return mReg.IsMatch(topic);
        }
    }
}